//
//  RHPlantTopoCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/1/5.
//

#import "RHPlantTopoCell.h"
#import "RHPlantTopoHEBATView.h"
#import "RHPlantTopoMEView.h"

NSString *const PETopoHEBatCell = @"PETopoHEBatCell";
NSString *const PETopoHEAioCell = @"PETopoHEAioCell";
NSString *const PETopoMECell    = @"PETopoMECell";

@interface RHPlantTopoCell()
@property (nonatomic ,strong) RHPlantDetailModel *topoModel;

@property (nonatomic ,strong) RHPlantTopoHEBATView *he_batView;

@property (nonatomic, strong) RHPlantTopoMEView *meView;
@end
@implementation RHPlantTopoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}

-(void)setTopoModel:(RHPlantDetailModel *)topoModel deviceTypeCode:(NSString*)deviceTypeCode
{
    _topoModel = topoModel;
    if ([self.reuseIdentifier isEqualToString:PETopoHEBatCell]) {
        [_he_batView setTopoModel:topoModel deviceTypeCode:deviceTypeCode];
        _he_batView.fullScreenAction = self.fullScreenAction;
    }
    
    if ([self.reuseIdentifier isEqualToString:PETopoMECell]) {
        _meView.topoModel = topoModel;
        _meView.fullScreenAction = self.fullScreenAction;
    }
}

- (void)setupUI{
    self.contentView.backgroundColor = CFTabViewBgColor;
    kWeakSelf;
    if ([self.reuseIdentifier isEqualToString:PETopoHEBatCell]) {
        _he_batView = [[RHPlantTopoHEBATView alloc]init];
        [self.contentView addSubview:_he_batView];
        [_he_batView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.insets(UIEdgeInsetsMake(15, 15, 0, 15));
        }];
    }
    
    if ([self.reuseIdentifier isEqualToString:PETopoMECell]) {
        _meView = [[RHPlantTopoMEView alloc]init];
        [self.contentView addSubview:_meView];
        [_meView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.insets(UIEdgeInsetsMake(15, 15, 0, 15));
        }];
    }
    
    
}



//家储示意图 (能量,馈网,电池,光伏,负载)
-(UIView*)indicatorViewWithTitle:(NSString*)title unit:(NSString*)unitStr Alignment:(NSTextAlignment)alignment;
{
    UIView *bgView = kView;
    bgView.layer.cornerRadius = 8;
    bgView.layer.masksToBounds = YES;
    bgView.backgroundColor = UIColor.clearColor;
    
    QMUILabel *titleLab = [[QMUILabel alloc]init];
    titleLab.textAlignment = alignment;
    titleLab.numberOfLines = 0;
    titleLab.text = title;
    titleLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:1];
    titleLab.font = [UIFont systemFontOfSize:12];
    [bgView addSubview:titleLab];
    
    QMUILabel *contentLab = [[QMUILabel alloc]init];
    contentLab.textAlignment = alignment;
    contentLab.text = [NSString stringWithFormat:@"-- %@",unitStr];
    contentLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:1];
    contentLab.font = [UIFont boldSystemFontOfSize:14];
    contentLab.tag = 100;
    [bgView addSubview:contentLab];
    
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(titleLab);
        make.top.mas_offset(0);
        make.height.offset(20);
    }];
    
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(0);
        make.right.mas_offset(0);
        make.top.equalTo(contentLab.mas_bottom);
        make.bottom.mas_offset(0);
        
    }];
    
    return bgView;
}

@end
